import { get } from './api.js'

// 接口地址配置
const apiUrls = {
  current: '/getJlldlz', // 精炼炉电流值
  voltage: '/getJlldlz', // 精炼炉电压值
  setCurrent: '/getJllsddl', // 精炼炉设定电流
  dustMonitor: '/getDhlcchcczxjk/', //除尘监控
}

// 获取精炼炉电流值
export const getCurrentData = () => {
  return get(apiUrls.current)
}

// 获取精炼炉电压值
export const getVoltageData = () => {
  return get(apiUrls.voltage)
}

// 获取精炼炉设定电流
export const getSetCurrentData = () => {
  return get(apiUrls.setCurrent)
}

// 获取除尘监控数据
export const getDustMonitorData = (id) => {
  return get(`${apiUrls.dustMonitor}${id}`)
}

// 批量获取所有数据
export const getAllMonitorData = async () => {
  try {
    const [
      currentData,
      voltageData,
      setCurrentData,
      dustMonitor1Data,
      dustMonitor2Data,
      dustMonitor3Data,
    ] = await Promise.all([
      getCurrentData(),
      getVoltageData(),
      getSetCurrentData(),
      getDustMonitorData(1),
      getDustMonitorData(2),
      getDustMonitorData(3),
    ])

    return {
      currentData,
      voltageData,
      setCurrentData,
      dustMonitor1: dustMonitor1Data,
      dustMonitor2: dustMonitor2Data,
      dustMonitor3: dustMonitor3Data,
    }
  } catch (error) {
    console.error('获取监测数据失败:', error)
    throw error
  }
}
